﻿// Copyright 2007-2009 Stuart Caborn, Alex Scordellis
//  
//  Licensed under the Apache License, Version 2.0 (the "License"); 
//  http://www.apache.org/licenses/LICENSE-2.0

using System;
using System.Linq;
using System.Collections.Generic;

namespace SampleApp.Monitored
{
    public class Book
    {
    }

    public class BookController
    {
        private readonly IBookService bookService;

        public BookController(IBookService bookService)
        {
            this.bookService = bookService;
            TempData = new Dictionary<string, object>();
        }

        public Dictionary<string, object> TempData { get; private set; }

        public void Search(string title)
        {
            TempData["foundBooks"] = bookService.Search(title);
        }

//        public void DeleteByTitle(string title)
//        {
//            foreach (var book in bookService.Search(title))
//            {
//                bookService.Delete(book);
//            }
//        }

        public void Delete(Book book)
        {
            bookService.Delete(book);
        }
    }

    public interface IBookService
    {
        IEnumerable<Book> Search(string title);
        void Delete(Book book);
    }

    internal class BookService : IBookService
    {
        public IEnumerable<Book> Search(string title)
        {
            throw new NotImplementedException();
        }

        public void Delete(Book book)
        {
            throw new NotImplementedException();
        }
    }
}